<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
// 
//  logout.php
//  www.6block.com
//  
//  Created by Will_Lee on 2011-05-18.
//  Copyright 2011 lishuzu. All rights reserved.
// 

class Logout extends CI_Controller {
	function __construct(){
		parent::__construct();
	}
	function index(){
		$username = '';
		
		$sina_keys = $this->session->userdata('sina_keys');

		if ($sina_keys) {
			//sina微博接入
			$this->load->helper('sinaweibo/sina_weibooauth');
			$sina_login = new WeiboClient( SINA_WB_AKEY, SINA_WB_SKEY, $sina_keys['last_key']['oauth_token'], $sina_keys['last_key']['oauth_token_secret']);
			$msg = $sina_login->oauth->post("http://api.t.sina.com.cn/account/end_session.json");
			if (isset($msg['name'])){
				$username = $msg['name'];
			}
		}
		$this->session->sess_destroy();
		showmessage($username.'退出成功', base_url().'index', 2);
	}
}
?>